<?php
include 'db.php';
include 'cart.php';

if(isset($_POST['addtocart'])){
	$qty = @$_POST['add_qty'];
	for($cnt=0;$cnt<count($qty);$cnt++){
		if($qty[$cnt] > 0){
			addCartSes(@$_POST['hiditemid'.$cnt],$qty[$cnt]);
		}
	}
	header("Location: items.php?item=".$_GET['item']."&res=1");
}

include 'inc/header.php';
?>
<!DOCTYPE HTML>
<html>
    <head>
    <meta charset=utf-8>
    <title>LEDLAMPS</title>
   
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script src="js/modernizr-1.7.min.js"></script><!-- this is the javascript allowing html5 to run in older browsers -->

     
    <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" title="html5doctor.com Reset Stylesheet" />
    
    <link rel="stylesheet" href="css/default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" media="screen" />
    
    <!-- in the CSS3 stylesheet you will find examples of some great new features CSS has to offer -->
    <link rel="stylesheet" type="text/css" href="css/css3.css" media="screen" />
    
    <!-- general stylesheet contains some default styles, you do not need this, but it helps you keep a uniform style -->
    <link rel="stylesheet" type="text/css" href="css/general.css" media="screen" />
    
    <!-- grid's will help you keep your website appealing to your users, view 52framework.com website for documentation -->
    <link rel="stylesheet" type="text/css" href="css/grid.css" media="screen" />
  
    
    
    </head>

<body>


<?php get_header('products','public'); ?>

<section class="shopcart-wrap">
	<div class="cartStatus"><a href="cart-canvas.php" class="cartView">show cart</a><p><?php cartStatus(); ?></p></div>
	<div class="clear"></div>
    
    


	
<div class="moreinfo" style="padding-bottom:15px;">
	<?php 
		if(@$_GET['res']){
	?>
    		<div class="alert alert-success" >
            	Item(s) has been added to cart.
            </div>
    <?php	
		}	
		$id = mysql_real_escape_string(@$_GET['item']);
		$id = strip_tags($id);
		$info = mysql_query("SELECT * FROM category WHERE id = $id");
		$infodata = mysql_fetch_array($info);
	?>
	
    
    	<img src="timthumb.php?src=<?php echo curPageURL_folder().str_replace("../../","",$infodata['image']); ?>&w=250" class="thumbnail" align="left" style="margin-right:15px;" />
        <h1><?php echo $infodata['name']; ?></h1>
  <h3 style="color:#999; font-style:italic; margin-top:10px;"><?php 
			switch($infodata['type']){
				case 'Y':
					echo "Dimmable";
				break;
				case 'N':
					echo "Non-Dimmable";
				break;
				case 'B':
					echo "Dimmable/Non-Dimmable";
				break;
			}
		 ?></h3>
    
    <ul class="featitems">
    	<?php
			$getfeatures = mysql_query("SELECT * FROM features LEFT JOIN cat_fetures ON cat_fetures.fet_id = features.id  WHERE cat_fetures.cat_id = $id");
			while($featlist = mysql_fetch_array($getfeatures)){
		?>
        	<li><?php echo $featlist['name']; ?></li>	
        <?php	
			}
		?>
    </ul>
  <div class="clear"></div>
</div>
<section class="row">
	<span style="font-style:italic; font-size:11px; color:#00CC00; padding-bottom:5px; display:block;">Tip: Hover field to view complete details</span>
 	<div class="rounded j-products box_shadow box-align-center">
    <form method="post" style="margin-bottom:0px;">
    	
    	<table width="100%" border="0" class="itemlist table-hover">
        	<tr>
            	<th><span class="updateLink" data-original-title="Item Description">Desc</span></th>
                <th><span class="updateLink" data-original-title="Wattage">W</span></th>
                <th><span class="updateLink" data-original-title="Halogen Wattage">HW</span></th>
                <th><span class="updateLink" data-original-title="Socket">Socket</span></th>
                <th><span class="updateLink" data-original-title="Beam Intensity">BI</span></th>
                <th><span class="updateLink" data-original-title="Beam Angle">BA</span></th>
                <th><span class="updateLink" data-original-title="Lifetime">Lifetime</span></th>
                <th><span class="updateLink" data-original-title="Dimmable">Dimm</span></th>
                <th><span class="updateLink" data-original-title="Lumen Output">LO</span></th>
                <th><span class="updateLink" data-original-title="Efficacy">Efficacy</span></th>
                <th><span class="updateLink" data-original-title="Units Per Pack">UPP</span></th>
                <th><span class="updateLink" data-original-title="Color Rendering Index">CRI</span></th>
                <th><span class="updateLink" data-original-title="Color Temp">CTemp</span></th>
                <th><span class="updateLink" data-original-title="12NC 929000">12NC</span></th>
                <?php if(@$_SESSION['salesName']){ ?><th>Price</th><?php } ?>
                <th>Qty</th>
            </tr>
         	<?php
				$showadd = NULL;
				if(is_numeric($id)){
					$getitems = mysql_query("SELECT * FROM items LEFT JOIN cat_items ON cat_items.item_id = items.itemId WHERE cat_items.cat_id = $id GROUP BY items.itemId ORDER BY items.itemDesc");
					$cnter_i = 0;
					if(mysql_num_rows($getitems) > 0){
						while($item_row = mysql_fetch_array($getitems)){
							
			?>
            		<tr>
                    	<td><span class="updateLink" data-original-title="<?php echo $item_row['itemDesc']; ?>"><?php echo substr($item_row['itemDesc'],0,10); ?>...</span></td>
                        <td><?php echo $item_row['wattage']; ?></td>
                        <td><?php echo $item_row['halogenWatt']; ?></td>
                        <td><?php echo $item_row['socket']; ?></td>
                        <td><?php echo $item_row['beamInt']; ?></td>
                        <td><?php echo $item_row['beamAngle']; ?></td>
                        <td><?php echo $item_row['lifetime']; ?></td>
                        <td><?php echo $item_row['dimmable']; ?></td>
                        <td><?php echo $item_row['lumenOutput']; ?></td>
                        <td><?php echo $item_row['efficacy']; ?></td>
                        <td><?php echo $item_row['unitsPerPack']; ?></td>
                        <td><?php echo $item_row['colorRendering']; ?></td>
                        <td><?php echo $item_row['colorTemp']; ?></td>
                        <td><?php echo $item_row['NC']; ?></td>
                       <?php if(@$_SESSION['salesName']){ ?> <td><?php echo $item_row['itemPrice']; ?></td><?php } ?>
                        <td><input type="text" name="add_qty[]" value="0" style="width:20px;">
                        	<input type="hidden" name="hiditemid<?php echo $cnter_i; ?>" value="<?php echo $item_row['itemId']; ?>" />
                        </td>
                    </tr>
            <?php
							$cnter_i++;
						}
					}else{
						$showadd = "display:none";
			?>
            		<tr>
            			<td colspan="8"><?php echo "No Data Found"; ?></td>
           			</tr>
            <?php		
					}
				}else{
					$showadd = "display:none";
			?>
            	<tr>
            		<td colspan="8"><?php echo "No Data Found"; ?></td>
           		</tr>
            <?php
					
				}
			?> 
        </table>
        <div align="right" style="padding:15px; <?php echo $showadd; ?>">
        	<input type="submit" name="addtocart" class="btn btn-primary" value="Add to Cart" />
        </div>
      </form>  
       
         
  	</div>  
</section>
 
<footer class="row">

	<div class="col_16 col">all rights reserved &copy; <a href="http://www.enavu.com">enavu network</a> | 52framework the framework from the future</div>

</footer>
 
</body>    <!-- start sidebarbox: Section 2 -->

<script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
		//for filters
		$(document).ready(function() {
			//for tooltip hovers
			$('.updateLink').tooltip({placement: 'right'});
			$('.edit-customer').tooltip();
			$('.edit-salesman').tooltip();
			$('.view-invoice').tooltip();		
		});
    </script>
</html>
